package com.lgt_enterprise_android.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.lgt_enterprise_android.R;
import com.lgt_enterprise_android.base.MyBaseAdapter;

//已发抢班
public class YFQBAdapter extends MyBaseAdapter {

    public YFQBAdapter(Context _mContext, JSONArray _mArray) {
        super(_mContext, _mArray);
    }


    @Override
    public View getView(int pos, View convertView, ViewGroup viewGroup) {
        ViewHolder holder;
        if (convertView == null) {
            holder = new ViewHolder();
            convertView = LayoutInflater.from(mContext).inflate(R.layout.item_first_fragment, null);
            holder.txtTitle = (TextView) convertView.findViewById(R.id.txt_title);
            holder.txtMoney = (TextView) convertView.findViewById(R.id.txt_money);
            holder.txtCount = (TextView) convertView.findViewById(R.id.txt_count);
            holder.txtTime = (TextView) convertView.findViewById(R.id.txt_time);
            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }

        JSONObject jsonObject = mArray.getJSONObject(pos);

        holder.txtTitle.setText(jsonObject.getJSONObject("position").getString("name"));
        holder.txtMoney.setText((int)jsonObject.getFloatValue("wage")+"元/小时");

        holder.txtCount.setText(jsonObject.getString("confirmedCount")+"/"+jsonObject.getString("totalDemand"));
        holder.txtTime.setText(jsonObject.getString("appShowDate"));

        return convertView;
    }

    public class ViewHolder {
        public TextView txtTitle;
        public TextView txtMoney;
        public TextView txtCount;
        public TextView txtTime;
    }
}
